<template>
  <!-- 添加或修改参数配置对话框 -->
  <el-dialog
    :title="`${detailName}详情`"
    v-model="open"
    :close-on-click-modal="false"
    width="700px"
    append-to-body
  >
    <el-form ref="formRef" label-width="100px">
      <el-row :gutter="gutter">
        <el-col :span="span" v-for="(item, index) in columns" :key="index">
          <el-form-item :label="item.label" :prop="item.prop">
            <div>{{ formData[item.prop] ? formData[item.prop] : "-" }}</div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup name="MatDetail">
// import { getMat } from "@/api/base/material/MaterialApi";
import { toRefs, computed } from "vue";
import { matColumn, prodColumn } from "./column";
const gutter = 20;
const span = 12;
const props = defineProps({
  formData: {
    type: Object,
    default: () => {},
  },
  type: {
    type: String,
    default: "",
  },
});

const { formData, type } = toRefs(props);
const open = defineModel("show");
const detailName = computed(() => {
  return type.value == "mat" ? "物料" : "产品";
});
const columns = computed(() => {
  return type.value == "mat" ? matColumn : prodColumn;
});

/** 取消按钮 */
function cancel() {
  open.value = false;
}
</script>

<style lang="scss" scoped></style>
